package com.nebula.api.modules.product.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nebula.api.modules.product.qo.ProductForm;
import com.nebula.api.modules.product.service.IShopProductService;
import com.nebula.api.modules.product.vo.ProductVo;
import com.nebula.api.modules.product.vo.ShopProductVo;
import link.ahsj.core.entitys.ApiModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品(单个商品,有库存量,例如iphone10,内存是256G,尺寸是9.6寸) 前端控制器
 * </p>
 *
 * @author my
 * @since 2022-09-17
 */
@RestController
@RequestMapping("cms/shopProduct")
public class ShopProductController {

    @Autowired
    private IShopProductService shopProductService;

    /**
     * @param page
     * @return
     */
    @RequestMapping("list")
    public ResponseEntity<ApiModel> page(Page page) {
        return ResponseEntity.ok(ApiModel.data(""));
    }

    /**
     * 处理recommend请求----精品推荐
     *
     * @param page
     * @return
     */
    @RequestMapping("recommend")
    public ResponseEntity<ApiModel> recommend(Page page) {
//        调用service层方法
        ProductVo productVO = shopProductService.selectProduct(1, "精品推荐");
//        把数据返回
        return ResponseEntity.ok(ApiModel.data(productVO));
    }

    /**
     * 处理hot请求----热门兑换
     *
     * @param page
     * @return
     */
    @RequestMapping("hot")
    public ResponseEntity<ApiModel> hot(Page page) {
//        调用service层方法
        ProductVo productVO = shopProductService.selectProduct(2, "热门兑换");
//        把数据返回
        return ResponseEntity.ok(ApiModel.data(productVO));
    }

    /*
     * 商品搜索
     * page 根据数据分析，这里需要传入page分页对象
     * productForm 前端传过来的表单数据，封装成一个类。
     *
     *  */
    @GetMapping("products")
    public ResponseEntity<ApiModel> products(Page page, ProductForm productForm) {

//        把数据返回
        return ResponseEntity.ok(ApiModel.data(""));
    }
}
